package com.sk.bilibili.apiMapper.bean;

import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 邵康
 * @date 2021/7/10 21:54
 */
@Data
public class RequestInfo {

    private String url;//  模板 信息 未填充
    private String method;
    private List<String> removeHeaders;
    private Map<String,String> addHeaders;
    private Class returnClass;
    private String path;

    public RequestInfo() {
        removeHeaders=new ArrayList<>();
        addHeaders=new HashMap<>();
    }

    public void addRemoveHeader(String key){
        removeHeaders.add(key);
    }

    public void addAddHeader(String key,String value){
        addHeaders.put(key,value);
    }

    public void addAddHeader(Map<String, String> baseAddHeaders) {
        addHeaders.putAll(baseAddHeaders);
    }

    public void addRemoveHeader(List<String> baseRemoveHeaders) {
        removeHeaders.addAll(baseRemoveHeaders);
    }

    public void check() {
        if(url.equals(""))throw new RuntimeException("url不能为空!");
        if(method.equals(""))throw new RuntimeException("请求方法不能为空!");
        if(path==null)path="";
    }

}
